package com.medeolinx.model.data;

// Generated May 1, 2012 12:20:21 AM by Hibernate Tools 3.4.0.CR1

import static javax.persistence.GenerationType.IDENTITY;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

/**
 * Album generated by hbm2java
 */
@Entity
@Table(name = "album", catalog = "medeo12_terrain")
public class Album implements java.io.Serializable {
	private static final long serialVersionUID = 2903061258991819395L;

	private Integer id;
	private User user;
	private String name;
	private List<Terrain> terrains = new ArrayList<Terrain>(0);

	public Album() {
	}

	public Album(String name) {
		this.name = name;
	}

	public Album(User user, String name, List<Terrain> terrains) {
		this.user = user;
		this.name = name;
		this.terrains = terrains;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "user_id")
	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Column(name = "name", nullable = false, length = 45)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@OneToMany(fetch = FetchType.EAGER, mappedBy = "album")
	@Fetch(value = FetchMode.SUBSELECT)
	@Cascade({ CascadeType.DELETE })
	public List<Terrain> getTerrains() {
		return this.terrains;
	}

	public void setTerrains(List<Terrain> terrains) {
		this.terrains = terrains;
	}

}
